##
# color_ramp.py - Created by Timothy Morey on 6/11/2012
#
# This file provides a ctypes wrapper for libnvn items defined in color-ramp.h.
#

import ctypes

from libnvn import nvn
import variant

MaxColorStops = 32

# ColorRampType enum values:
ColorRampTypeSmooth = 0
ColorRampTypeStepped = 1

# ColorStopValueType enum values:
ColorStopValueTypeAbsolute = 0
ColorStopValueTypePercentage = 1

class ColorStop(ctypes.Structure):
    _fields_ = [
               ('Value', variant.Variant),
               ('Color', ctypes.c_int),
              ]

class ColorRamp(ctypes.Structure):
    _fields_ = [
                ('RampType',      ctypes.c_int),
                ('StopValueType', ctypes.c_int),
                ('Stops',         ColorStop * MaxColorStops),
                ('NStops',        ctypes.c_int),
               ]

DefaultColorRamp = ColorRamp(RampType = ColorRampTypeSmooth, 
                             StopValueType = ColorStopValueTypePercentage,
                             NStops = 6)
DefaultColorRamp.Stops[0] = ColorStop(Value = variant.CreateVariant(0.0),
                                      Color = 0xFFFFFFFF)
DefaultColorRamp.Stops[1] = ColorStop(Value = variant.CreateVariant(0.2),
                                      Color = 0xFFFF0000)
DefaultColorRamp.Stops[2] = ColorStop(Value = variant.CreateVariant(0.4),
                                      Color = 0xFFFFFF00)
DefaultColorRamp.Stops[3] = ColorStop(Value = variant.CreateVariant(0.6),
                                      Color = 0xFF00FF00)
DefaultColorRamp.Stops[4] = ColorStop(Value = variant.CreateVariant(0.8),
                                      Color = 0xFF00FFFF)
DefaultColorRamp.Stops[5] = ColorStop(Value = variant.CreateVariant(1.0),
                                      Color = 0xFF0000FF)